function _mouseHandler(isDown: boolean, dom: HTMLElement) {
  if (!dom.classList.contains("key")) {
    dom = dom.parentElement!;
    if (!dom.classList.contains("key")) {
      return;
    }
  }
  const key = dom.dataset.code;
  //   isDown ? Play(key) : stop(key);
}
export function mouseHandler(div: HTMLDivElement) {
  div.onmousedown = function (e) {
    _mouseHandler(true, e.target as HTMLElement);
    window.onmouseup = function () {
      _mouseHandler(false, e.target as HTMLElement);
      window.onmouseup = null;
    };
  };
}
const keyMap = {};
const keySet = new Set();
window.onkeydown = function (e: KeyboardEvent) {
  const code = keyMap[e.code];
  if (code && !keySet.has(code)) {
    // Play(code);
    keySet.add(code);
  }
};

window.onkeyup = function (e: KeyboardEvent) {
  const code = keyMap[e.code];
  if (code) {
    // stop(code);
    keySet.delete(code);
  }
};
